﻿using Microsoft.Xna.Framework;

namespace Microsoft.Goldenlight.Framework.Controls
{
    /// <summary>
    /// 	A Style is used by every Control. It is used to control information that does not change or is unlikely to change during the execution of the application.
    /// </summary>
    /// <remarks>
    /// 	Helps define the look and behavior of a Control. Derive from Style to further specialize a style for your custom controls.
    /// </remarks>
    public class Style : LifetimeObject
    {
        #region Static Operations

        #endregion

        #region Fields & Properties

        protected bool _focusable;

        /// <summary>
        /// 	If the Control can be focused.
        /// </summary>
        public bool Focusable
        {
            get
            {
                return _focusable;
            }
            set
            {
                _focusable = value;
            }
        }

        protected bool _hasBorder;

        /// <summary>
        /// 	If the Control has a border.
        /// </summary>
        public bool HasBorder
        {
            get
            {
                return _hasBorder;
            }
            set
            {
                _hasBorder = value;
            }
        }

        protected Color[] _borderColor = new Color[10];

        /// <summary>
        /// 	Used to draw a border around the bounds of a Control with the specified color.
        /// </summary>
        /// <remarks>
        /// 	If a control uses BorderColor, it must support at least the CustomColor.Base value.
        /// </remarks>
        public Color[] BorderColor
        {
            get
            {
                return _borderColor;
            }
        }

        protected Color[] _fillColor = new Color[10];

        /// <summary>
        /// 	Used to fill the bounds of a Control with the specified color, if opaque.
        /// </summary>
        /// <remarks>
        /// 	If a control uses FillColor, it must support at least the CustomColor.Base value.
        /// </remarks>
        public Color[] FillColor
        {
            get
            {
                return _fillColor;
            }
        }

        protected bool _opaque = true;

        /// <summary>
        /// 	If the Control is not translucent.
        /// </summary>
        public bool Opaque
        {
            get
            {
                return _opaque;
            }
            set
            {
                _opaque = value;
            }
        }

        #endregion

        #region Overrides of LifetimeObject

        #region Implementation of ICloneable

        /// <summary>
        /// 	Called by Clone. Objects need to implement this method to copy all public properties not marked with TorqueCloneIgnore attribute.
        /// </summary>
        /// <param name="newLifetimeObject"> The object to be copied over. </param>
        public override void CopyTo(LifetimeObject newLifetimeObject)
        {
            base.CopyTo(newLifetimeObject);
            var newStyle = newLifetimeObject as Style;
            if (newStyle != null)
            {
                newStyle._focusable = _focusable;
                newStyle._hasBorder = _hasBorder;
                newStyle._borderColor = _borderColor;
                newStyle._fillColor = _fillColor;
                newStyle._opaque = _opaque;
            }
        }

        #endregion

        #region Implementation of IDisposable

        /// <summary>
        /// 	Releases all resources used by the object class.
        /// </summary>
        /// <param name="disposing"> true to release both managed and unmanaged resources; false to release only unmanaged resources. </param>
        protected override void Dispose(bool disposing)
        {
            _isDisposed = true;
            if (disposing)
            {
                _focusable = false;
                _hasBorder = false;
                _opaque = true;
            }
            base.Dispose(disposing);
        }

        #endregion

        #endregion
    }
}